package club.ruanx.movie.service.impl;


import club.ruanx.bean.PageBean;
import club.ruanx.core.service.base.BaseServiceImpl;
import club.ruanx.movie.entity.News;
import club.ruanx.movie.repository.NewsRepository;
import club.ruanx.movie.service.NewsService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 阮胜
 * @date 2018/11/11 19:50
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class NewsServiceImpl extends BaseServiceImpl<News, String, NewsRepository> implements NewsService {
    @Override
    public Page<News> findAll(PageBean pageBean) {
        return repository.findAllByOrderByCreateTimeDesc(pageBean.toPageable());
    }

    @Override
    public News findTop1() {
        return repository.findTop1ByOrderByCreateTimeDesc().orElse(null);
    }
}
